package practise.mulitThreads.ConcurrentInPractice.secondTime.Memorizer;

/**
 * Created by Richard on 7/28/2014.
 */
public class ComputerObject {
    private Calculator calculator;
    public void accept(Calculator calculator){
        calculator.addComputeObject(this);
    }

    public Calculator getCalculator() {
        return calculator;
    }

    public void setCalculator(Calculator calculator) {
        this.calculator = calculator;
    }

    private int id;
    private int value;

    public ComputerObject(int id, int value) {
        this.id = id;
        this.value = value;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getValue() {
        return value;
    }

    public void setValue(int value) {
        this.value = value;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        ComputerObject that = (ComputerObject) o;

        if (id != that.id) return false;
        if (value != that.value) return false;

        return true;
    }


    @Override
    public int hashCode() {
        int result = id;
        result = 31 * result + value;
        return result;
    }
}
